﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace JTicket.UI.Extention.IHandler
{
    public class TitleSetStatu : IHttpHandler
    {

        #region IHttpHandler 成员

        public bool IsReusable
        {
            get { return false; }
        }
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest request = context.Request;
            HttpResponse response = context.Response;
            string TitleCode = request.QueryString["TitleCode"].ToString();
            string result =BLL.D_TitleInfo.SetStatus(TitleCode);
            response.Write(result);
        }
        #endregion
    }

    public class TitleGetModel : IHttpHandler
    {

        #region IHttpHandler 成员

        public bool IsReusable
        {
            get { return false; }
        } 
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest request = context.Request;
            HttpResponse response = context.Response;
            string TitleCode = request.QueryString["TitleCode"].ToString();
            BLL.D_TitleInfo bllTitle = new BLL.D_TitleInfo();
            JTicket.Model.D_TitleInfo model =
               bllTitle.GetModel(TitleCode);
            response.Write("[");
            response.Write(JsonHelper.ObjectToJson(model));
            response.Write("]");
        }
        #endregion
    }

    public class ThGetHandler : IHttpHandler
    {

        #region IHttpHandler 成员

        public bool IsReusable
        {
            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {
            HttpRequest request = context.Request;
            HttpResponse response = context.Response; 
            int pages = 0;
            int flag = 0;
            BLL.C_TheaterInfo bllTheaterInfo = new BLL.C_TheaterInfo();
            List<Model.C_TheaterInfo> list =bllTheaterInfo.GetListByCurLevel(0, 200, ref pages, "");
            response.Write("[");
            flag = list.Count;
            if (flag > 0)
            {
                foreach (var x in list)
                {
                    response.Write(JsonHelper.ObjectToJson(x));
                    if (--flag > 0)
                    {
                        response.Write(",");
                    }
                }
            }
            response.Write("]");

        }

        #endregion
    }

    public class TitleTypeHandler : IHttpHandler
    {
        #region IHttpHandler Members

        public bool IsReusable
        {

            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {
            HttpResponse response = context.Response;
            HttpRequest request = context.Request;

            List<Model.C_CodeNote> list=
                BLL.C_CodeNote.GetListAllByGroupCod("TitleSort");
            int flag = list.Count();
           
                response.Write("[");
                if (flag > 0)
                {
                    foreach (var x in list)
                    {
                        response.Write(JsonHelper.ObjectToJson(x));
                        if (--flag > 0)
                        {
                            response.Write(",");
                        }
                    }
                }
                else {
                    response.Write(JsonHelper.ObjectToJson(new Model.C_CodeNote()));
                }
                response.Write("]");
                response.End();
           
           
        }
        #endregion
    }


    public class TitleHandler : IHttpHandler
    {
        #region IHttpHandler Members

        public bool IsReusable
        {

            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {
            HttpResponse response = context.Response;
            HttpRequest request = context.Request;
            BLL.D_OperInfo bllOper = new BLL.D_OperInfo();
            BLL.C_TheaterInfo bllTheaterInfo = new BLL.C_TheaterInfo();
            BLL.D_TitleInfo bllTitle = new BLL.D_TitleInfo();
            Model.D_OperInfo oper = bllOper.Oper();
            Model.C_TheaterInfo Group = bllTheaterInfo.GetModel(oper.ThCode);
            List<Model.D_TitleInfo> list = bllTitle.GetList(20,
                 oper.ThCode, Group.GroupRole);
            int flag = list.Count();
            response.Write("[");
            foreach (var x in list)
            {
                response.Write(JsonHelper.ObjectToJson(x));
                if (--flag > 0)
                {
                    response.Write(",");
                }
            }
            response.Write("]");
            response.End();
        }
        #endregion
    }

    public class BoardListTop6Handler : IHttpHandler
    {

        #region IHttpHandler 成员

        public bool IsReusable
        {
            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {
            StringBuilder sb = new StringBuilder();
            HttpRequest request = context.Request;
            HttpResponse response = context.Response;
            BLL.D_Boardinfo bllBoard = new BLL.D_Boardinfo();
            sb.Append("<table width=\"100%\" border=\"0\" bordercolordark=\"#3890B5\" bordercolorlight=\"#6591BE\"");
            sb.Append("align=\"center\" cellpadding=\"1\" cellspacing=\"1\">");
            sb.Append(" <tr>");
            sb.Append("<td align=\"center\" bgcolor=\"#3890B5\" style=\"height: 12px\">");
            sb.Append("<span class=\"B\">标题</span>");
            sb.Append("</td>");
            sb.Append("<td align=\"center\" bgcolor=\"#3890B5\" style=\"height: 12px; width: 150px;\">");
            sb.Append("<span class=\"B\">时间</span>");
            sb.Append("</td>");
            sb.Append("</tr>");

            List<Model.D_Boardinfo> BList = bllBoard.GetList(6);

            if (BList.Count > 0)
            {
                for (var i = 0; i < BList.Count; i++)
                {
                    sb.Append("<tr>");
                    sb.Append("<td class=\"td1\" align=\"center\" bgcolor=\"#3890B5\" style=\"height: 12px\">");
                    sb.Append("&nbsp;&nbsp;" + (i + 1) + "、&nbsp;&nbsp;&nbsp;<a href=\"#\" onclick=\"window.open('S_Board.aspx?BoardID=" + BList[i].id + "','newwindow','height=500,width=695,top=0,left=0,toolbar=no, menubar=no,scrollbars=yes,resizable=no,location=no,status=no')\">" + BList[i].sTitle + "</a>");
                    sb.Append("</td>");
                    sb.Append("<td class=\"td1\" align=\"center\" bgcolor=\"#3890B5\" style=\"height: 12px; width: 150px;\">");
                    sb.Append(BList[i].sdate + BList[i].Stime);
                    sb.Append("</td>");
                    sb.Append("</tr>");
                }
            }
            sb.Append("<tr>");
            sb.Append("<td align=\"left\" bgcolor=\"#F6F6F6\">");
            sb.Append("&nbsp;");
            sb.Append("</td>");
            sb.Append("<td align=\"left\" bgcolor=\"#F6F6F6\">");
            sb.Append("</td>");
            sb.Append("</tr>");
            sb.Append("</table>");
            response.Write(sb.ToString());
        }
        #endregion
    }


    public class TitleAllHandler : IHttpHandler
    {

        #region IHttpHandler Members

        public bool IsReusable
        {
            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {


            HttpRequest request = context.Request;
            HttpResponse response = context.Response;
            BLL.D_OperInfo bllOper = new BLL.D_OperInfo();
            List<Model.D_TitleInfo> list = BLL.D_TitleInfo.GestListAll(
                bllOper.Oper().ThCode);
            int flag = list.Count();
            response.Write("[");
            if (flag > 0)
            {
                foreach (var x in list)
                {
                    response.Write(JsonHelper.ObjectToJson(x));
                    if (--flag > 0)
                    {
                        response.Write(",");
                    }
                }
            }
            response.Write("]");
            response.End();


        }

        #endregion
    }

    public class TitleAllByHandler : IHttpHandler
    {

        #region IHttpHandler Members

        public bool IsReusable
        {
            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {

            HttpRequest request = context.Request;
            HttpResponse response = context.Response;
            DateTime begin = Convert.ToDateTime(request.QueryString["Btime"].ToString());
            DateTime end = Convert.ToDateTime(request.QueryString["Etime"].ToString());
            BLL.D_OperInfo bllOper = new BLL.D_OperInfo();
            List<Model.D_TitleInfo> list = BLL.D_TitleInfo.GestListAll(
                bllOper.Oper().ThCode, begin, end);
            int flag = list.Count();
            response.Write("[");
            if (flag > 0)
            {
                foreach (var x in list)
                {
                    response.Write(JsonHelper.ObjectToJson(x));
                    if (--flag > 0)
                    {
                        response.Write(",");
                    }
                }
            }


            response.Write("]");
            response.End();

        }
        #endregion
    }
}